/*
 * StatisticsManager.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef STATISTICSMANAGER_H_
#define STATISTICSMANAGER_H_

#include <string>
#include <vector>

using namespace std;

class StatisticsManager
{
public:
	/*!
	 * Constructor with path to file @param filename and number of
	 * bins @param n_bins used to construct a normalized distribution.
	 */
	StatisticsManager(string filename, unsigned int n_bins);
	/*!
	 * Pick a value based on the given distribution.
	 */
	double pick_values_from_distribution();
	/*!
	 * Returns number of bins used.
	 */
	double get_number_of_bins(){return n_bins;};
	/*!
	 * Returns current bin size.
	 */
	double get_number_bin_size(){return bin_size;};
	/*!
	 * Returns bins probability for a certain value.
	 */
	double get_binned_probability(double value);
private:
	/*!
	 * Number of bins.
	 */
	unsigned int n_bins;
	/*!
	 * Bin size.
	 */
	double bin_size;
	/*!
	 * Vector that contains the normal distribution. Structure: array[bin index][0] = min value, array[bin index][1] = max value,
	 * array[bin index][2] = probability for the bin, array[bin index][3] = sumarized probability (prob for value < max value)
	 */
	vector<vector<double> > norm_distribution;
	/*!
	 * Return a list of values from a given file.
	 */
	vector<double> read_value_list(string filename);
	/*!
	 * Generates a normal distribution from a value list and a given number of bins.
	 */
	vector<vector<double> > generate_distribution(vector<double> value_list, unsigned int n_bins);
};



#endif /* STATISTICSMANAGER_H_ */
